package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Region;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.service.ITravelService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {
    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;

    @GetMapping("/hotRegion")
    public Object hotRegion(){
        List<Region> regions = regionService.getHotRegion();
        return JsonResult.success(regions);
    }

    @GetMapping("/search")
    public Object search(String regionId){
        List<Destination> destinations = destinationService.search(regionId);
        return JsonResult.success(destinations);
    }

    // 吐司
    @GetMapping("/getToasts")
    public Object getToasts(String destId){
        return JsonResult.success(destinationService.getToasts(destId));
    }

    // 概括，获取目的地下所有的概括，并显示分类下的所有攻略
    @GetMapping("/getCatalogs")
    public Object getCatalogs(String destId){
        return JsonResult.success(destinationService.getCatalogs(destId));
    }

    // 攻略，获取目的地下所有的攻略
    @GetMapping("/getStrategies/viewnumTop3")
    public Object getStrategies(String destId){
        return JsonResult.success(strategyService.findByDestId(destId));
    }

    // 攻略，获取目的地下所有的攻略
    @GetMapping("/getTravels/viewnumTop3")
    public Object getTravels(String destId){
        return JsonResult.success(travelService.findByDestId(destId));
    }

    @GetMapping("/list")
    public Object list(){
        return JsonResult.success(destinationService.listAll());
    }
}
